package com.tianheng.wanzhou.datacollecting;

import com.tianheng.wanzhou.datacollecting.netty.jiangsha.GatherServer;
import com.tianheng.wanzhou.datacollecting.db.entity.HuafangZhengjingHis;
import com.tianheng.wanzhou.datacollecting.db.entity.JiangshaHis;
import com.tianheng.wanzhou.datacollecting.db.entity.KaiyuanZhengjingHis;
//import com.tianheng.wanzhou.datacollecting.netty.jiangsha.GatherServer;
import org.mybatis.spring.annotation.MapperScan;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.boot.CommandLineRunner;
import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.SpringBootApplication;
import org.springframework.scheduling.annotation.EnableScheduling;

import java.util.HashMap;
import java.util.Map;

@SpringBootApplication
@EnableScheduling
@MapperScan("com.tianheng.wanzhou.datacollecting.db.mapper")
public class DataCollectingApplication implements CommandLineRunner {
    //存储浆纱整经长度
    public static Map<String, JiangshaHis> jiangshaHis = new HashMap<>();
    public static Map<String, KaiyuanZhengjingHis> kaiyuanZhengjingHis = new HashMap<>();
    public static Map<String, HuafangZhengjingHis> huafangZhengjingHis = new HashMap<>();
    //存储浆纱整经停机
    public static Map<String, Integer> stopNum = new HashMap<>();
    //存储空压机电流功耗
    public static Map<String, Float> ampsHis = new HashMap<>();
    public static Map<String, Double> powerHis = new HashMap<>();

    @Autowired
    GatherServer gatherServer;

    public static void main(String[] args) {
        //输入日志
        final Logger logger = LoggerFactory.getLogger(DataCollectingApplication.class);
        SpringApplication.run(DataCollectingApplication.class, args);

    }

    @Override
    public void run(String... args) throws Exception {
        try {
            gatherServer.setPort(50080);
            gatherServer.run();
        } catch (Exception e) {
            System.out.println(e.getMessage());
        }
    }
}
